﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Entity.ModelConfiguration;
using System.ComponentModel.DataAnnotations;

namespace ERPStore.NewsLetters.Repositories.Mapping
{
	internal class EmailSentMap : EntityTypeConfiguration<Datas.EmailSentData>
	{
		public EmailSentMap()
		{
			this.HasKey(e => e.Id);
			this.Property(e => e.Id)
				.IsRequired()
				.HasDatabaseGeneratedOption(System.ComponentModel.DataAnnotations.Schema.DatabaseGeneratedOption.Identity);

			this.Property(e => e.SentDate)
				.IsRequired();

			this.Property(e => e.CampaignId)
				.IsRequired();

			this.HasOptional(p => p.EmailRecipient)
				.WithMany(l => l.EmailSentList)
				.HasForeignKey(k => k.EmailRecipientId);

			this.ToTable("NewsLetterEmailSent");
		}
	}
}
